
/*******************************************************************************
 * 审稿费预付单：(根据付款对象拉取银行卡信息)
 *
 * @param obj
 * @return
 */
function getcwSGFYFDAccount() {

    // 获取出版社对象
    var JIAFANG = $("#sgfyfd_addWinForm input[qucln='PUB_ID']").val();

    //如果修改出版社，则清空明细的数据
    $("#sgfyfd_addWinForm input[qucln='PUB_ID']").change(function(){
        $('#sgfyfd_addItemDatagrid').datagrid('loadData',{total:0,rows:[]});
    });

    $.ajax({
        type: 'post',
        url: _m_url + 'fxa/getcontractnobycbsid',
        data: {
            'VENDOR_ID': JIAFANG
        },
        success: function (data) {
            if (data.length == 1) {
                //如果付款对象拉取的时候银行的户号和户名不止一条数据那么就拉取过来进行手动选择
                $("#sgfyfd_addWinForm input[qucln=CARD_NO]").val(
                    data[0].ID);
                $("#sgfyfd_addWinForm input[qucln=CARD_NO]").attr(
                    "chan", "T");
                $("#sgfyfd_addWinForm input[qucln=CARD_NO]").next()
                    .val(data[0].BANK_NO);

                $("#sgfyfd_addWinForm input[qucln=ACCOUNT_NAME]").val(
                    data[0].ACCOUNT_NAME);
                $("#sgfyfd_addWinForm input[qucln=ACCOUNT_NAME]").attr(
                    "chan", "T");
                $("#sgfyfd_addWinForm input[qucln=ACCOUNT_NAME]")
                    .next().val(data[0].ACCOUNT_NAME);

                $("#sgfyfd_addWinForm input[qucln=BANK_NAME]").val(
                    data[0].BANK_NAME);
                $("#sgfyfd_addWinForm input[qucln=BANK_NAME]").attr(
                    "chan", "T");
                $("#sgfyfd_addWinForm input[qucln=BANK_NAME]")
                    .next().val(data[0].BANK_NAME);

                BANK_NAME
            } else {
                $("#sgfyfd_addWinForm input[qucln=CARD_NO]").val();
                $("#sgfyfd_addWinForm input[qucln=CARD_NO]").attr("chan", "T");
                $("#sgfyfd_addWinForm input[qucln=CARD_NO]").next().val('');

                $("#sgfyfd_addWinForm input[qucln=ACCOUNT_NAME]").val();
                $("#sgfyfd_addWinForm input[qucln=ACCOUNT_NAME]").attr("chan", "T");
                $("#sgfyfd_addWinForm input[qucln=ACCOUNT_NAME]").next().val('');

                $("#sgfyfd_addWinForm input[qucln=BANK_NAME]").val();
                $("#sgfyfd_addWinForm input[qucln=BANK_NAME]").attr("chan", "T");
                $("#sgfyfd_addWinForm input[qucln=BANK_NAME]").next().val('');

            }
        }
    })
}



/**
 * *审稿费预付单单中：选择单据按钮事件
 */
function chooseDZCL(){
    // 获取供应商
    var PUB_ID=$('#sgfyfd_addWinForm').find('input[qucln=PUB_ID]').val();
    if (PUB_ID==''){
        $.messager.alert('提示','请选择出版社！');
        return;
    }
    _data_qw('sgft','ds_cw_reviewFee_item2','sgfyfd_sure1','44','clowQuery','');
}

//选择单据弹出窗口的回调函数
function clowQuery(){
    $('#sgft_dataQuery').attr('onclick','clcjsQuery(this)');
}

//结算清单的选择单据的查询按钮
function clcjsQuery(obj){
    var prefix=$(obj).attr('pre');
    var dsId=$(obj).attr('dsid');
    var resultDG = 'DATA_DATALIST';
    var comUseConf='commUseD';
    var PUB_ID=$('#sgfyfd_addWinForm').find('input[qucln=PUB_ID]').val();
    var otherConfig = "1-PUB_ID-"+PUB_ID+"-inc|+";
    var comUse = parseConfig(prefix+"_"+comUseConf);
    var useConf = otherConfig+comUse;

    //获取对账明细的数据行
    var dzmxRows = $('#sgfyfd_addItemDatagrid').datagrid('getRows');
    var ids='';
    if(dzmxRows.length>0){
        for(var i=0,j=dzmxRows.length;i<j;i++){
            ids+="'"+dzmxRows[i].I_INFO+"',";
        }
        ids=ids.substring(0,ids.lastIndexOf(","));
        ids=" and I_INFO not in("+ids+")";
    }



    //将YW_ID组成一个'YW_ID',字符串
    //将datagrid 获取到后 就用变量存起来,不然每次 jquery 获取都是一次耗时操作
    var queryDG=$('#'+prefix+"_"+resultDG);
    queryDG.datagrid({
        idField:"I_INFO",
        pageNumber:1,
        pagination:true,
        pageList:[300],
        url:_m_url+'framework/loadDataQ',
        queryParams:{'dsId':dsId,'config':useConf,"originalSql":ids}
    });
}

/**
 * 弹窗的确定按钮
 *
 * @return
 */
function sgfyfd_sure1(){
    // 关闭弹窗
    $('#sgft_DATA_PARENT_PANEL').window('close');
    // 原有明细数据
    var oldRows = $('#sgfyfd_addItemDatagrid').datagrid('getRows');
    // 获取选择的数据
    var selRows = $('#sgft_DATA_DATALIST').datagrid('getSelections');

    // 关闭弹出窗口的editor
    for(var i=0;i<selRows.length;i++){
        var index=$('#sgft_DATA_DATALIST').datagrid("getRowIndex",selRows[i]);
        $('#sgft_DATA_DATALIST').datagrid('endEdit',index);
    }

    for ( var j = 0; j < selRows.length; j++) {
        $('#sgfyfd_addItemDatagrid').datagrid('appendRow', {
            XT_ID:selRows[j].XT_ID,
            YINCI:selRows[j].YINCI,
            NO_REAL_MONEY:selRows[j].NO_REAL_MONEY,
            TAX_RATE:selRows[j].TAX_RATE,
            TAX_MONEY:selRows[j].TAX_MONEY,
            REAL_MONEY:selRows[j].REAL_MONEY,
            I_INFO:selRows[j].I_INFO

        });
    }
}

/**
 * 纸厂对账单的删除明细的按钮
 */
function deleteDZCL(obj,dgUrl,queryParams){
    // 获取选中的行
    var oldRows = $('#sgfyfd_addItemDatagrid').datagrid('getSelections');
    for(var i=0;i<oldRows.length;i++){
        var rowIndex= $('#sgfyfd_addItemDatagrid').datagrid('getRowIndex',oldRows[i]);
        $('#sgfyfd_addItemDatagrid').datagrid('deleteRow',rowIndex);
    }
}

/**
 * 纸厂对账单的删除明细的按钮
 */
function deleteLSZTWH(obj,dgUrl,queryParams){
    // 获取选中的行
    var oldRows = $('#lsztwh_addItemDatagrid').datagrid('getSelections');
    for(var i=0;i<oldRows.length;i++){
        var rowIndex= $('#lsztwh_addItemDatagrid').datagrid('getRowIndex',oldRows[i]);
        $('#lsztwh_addItemDatagrid').datagrid('deleteRow',rowIndex);
    }
}


function clearpubid(){

}



